package com.example.jn_dxs.Ui.adapter;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.jn_dxs.Bean.PopuBean;
import com.example.jn_dxs.R;
import com.example.jn_dxs.Utlis.ItemOnClickListenter;

import java.util.List;

public class StatisticsAdapter extends BaseQuickAdapter<PopuBean, BaseViewHolder> {
    private ItemOnClickListenter<PopuBean> listenter;
    private int type;

    public StatisticsAdapter(int layoutResId, @Nullable List<PopuBean> data) {
        super(layoutResId, data);
    }

    public StatisticsAdapter(@Nullable List<PopuBean> data) {
        super(data);
    }

    public StatisticsAdapter(int layoutResId) {
        super(layoutResId);
    }

    public void setListenter(ItemOnClickListenter<PopuBean> listenter) {
        this.listenter = listenter;
    }

    public void setType(int type) {
        this.type = type;
    }

    @Override
    protected void convert(BaseViewHolder helper, PopuBean item) {
        helper.setText(R.id.Name, item.getName());
        helper.itemView.setOnClickListener(v -> {
            if (listenter != null) {
                listenter.ItemOnClick(helper.itemView, item, type);
            }
        });
    }
}
